package com.fenghongzhang.kotlin1903.goods

import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory

object RetrofitManagerGoods {

    const val BASE_URL ="http://www.qubaobei.com/"

     private val retrofit:Retrofit =  Retrofit.Builder()
        .baseUrl(BASE_URL)
        .client(OkHttpClient().newBuilder()
            .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)).build())
        .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
        .addConverterFactory(GsonConverterFactory.create())
        .build()


    //泛型方法
    fun <T> create(clzss:Class<T>) : T = retrofit.create(clzss)

    //简化写法
    inline fun <reified T> create() :T = create(T::class.java)






}